
<!DOCTYPE HTML>
<html lang="zh" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>绘图 · Pine Script 用户手册中文版</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="剑客">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="7extend.html" />
    
    
    <link rel="prev" href="5context.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="輸入並搜尋" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../Introduction.html">
            
                <a href="../Introduction.html">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../quickstart/">
            
                <a href="../quickstart/">
            
                    
                    快速开始
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../quickstart/example.html">
            
                <a href="../quickstart/example.html">
            
                    
                    Pine Script 示例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../quickstart/studyVsStrategy.html">
            
                <a href="../quickstart/studyVsStrategy.html">
            
                    
                    “study” 与 “strategy”
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../quickstart/model.html">
            
                <a href="../quickstart/model.html">
            
                    
                    Pine Script 执行模型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../quickstart/series.html">
            
                <a href="../quickstart/series.html">
            
                    
                    序列
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../quickstart/understanding.html">
            
                <a href="../quickstart/understanding.html">
            
                    
                    理解 Pine Script
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../quickstart/editor.html">
            
                <a href="../quickstart/editor.html">
            
                    
                    Pine 编辑器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="../quickstart/next.html">
            
                <a href="../quickstart/next.html">
            
                    
                    下一步
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../fundamentals/">
            
                <a href="../fundamentals/">
            
                    
                    语言基础
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../fundamentals/1structure.html">
            
                <a href="../fundamentals/1structure.html">
            
                    
                    脚本结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../fundamentals/2version.html">
            
                <a href="../fundamentals/2version.html">
            
                    
                    版本
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../fundamentals/3comment.html">
            
                <a href="../fundamentals/3comment.html">
            
                    
                    注释
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../fundamentals/4identifier.html">
            
                <a href="../fundamentals/4identifier.html">
            
                    
                    标识符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../fundamentals/5line.html">
            
                <a href="../fundamentals/5line.html">
            
                    
                    换行
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../fundamentals/6type.html">
            
                <a href="../fundamentals/6type.html">
            
                    
                    类型系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="../fundamentals/7operator.html">
            
                <a href="../fundamentals/7operator.html">
            
                    
                    运算符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="../fundamentals/8function.html">
            
                <a href="../fundamentals/8function.html">
            
                    
                    函数和注解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="../fundamentals/9expressions.html">
            
                <a href="../fundamentals/9expressions.html">
            
                    
                    表达式、声明和语句
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="../fundamentals/10function.html">
            
                <a href="../fundamentals/10function.html">
            
                    
                    函数声明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.11" data-path="../fundamentals/11model.html">
            
                <a href="../fundamentals/11model.html">
            
                    
                    执行模型
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="./">
            
                <a href="./">
            
                    
                    基本功能
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="1alert.html">
            
                <a href="1alert.html">
            
                    
                    警报
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="2array.html">
            
                <a href="2array.html">
            
                    
                    数组
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="3barstate.html">
            
                <a href="3barstate.html">
            
                    
                    柱状态，内置变量 barstate.*
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="4color.html">
            
                <a href="4color.html">
            
                    
                    颜色
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="5context.html">
            
                <a href="5context.html">
            
                    
                    上下文切换和 security 函数
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.5.6" data-path="6drawing.html">
            
                <a href="6drawing.html">
            
                    
                    绘图
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="7extend.html">
            
                <a href="7extend.html">
            
                    
                    延长和扩展交易数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="8reapint.html">
            
                <a href="8reapint.html">
            
                    
                    指标重绘
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.9" data-path="9nonstandard.html">
            
                <a href="9nonstandard.html">
            
                    
                    非标准图表类型数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.10" data-path="10session.html">
            
                <a href="10session.html">
            
                    
                    交易时段和时间信息
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.11" data-path="11strategies.html">
            
                <a href="11strategies.html">
            
                    
                    策略
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.12" data-path="12table.html">
            
                <a href="12table.html">
            
                    
                    图表
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../annotations/">
            
                <a href="../annotations/">
            
                    
                    注解概览
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../annotations/1study.html">
            
                <a href="../annotations/1study.html">
            
                    
                    指标注解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../annotations/2plot.html">
            
                <a href="../annotations/2plot.html">
            
                    
                    绘图注解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../annotations/3input.html">
            
                <a href="../annotations/3input.html">
            
                    
                    脚本输入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../annotations/4price.html">
            
                <a href="../annotations/4price.html">
            
                    
                    价格水平，hline
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../annotations/5fill.html">
            
                <a href="../annotations/5fill.html">
            
                    
                    用 fill 填充背景
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../annotations/6barcolor.html">
            
                <a href="../annotations/6barcolor.html">
            
                    
                    使用 barcolor 为 series 着色
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../annotations/7bg.html">
            
                <a href="../annotations/7bg.html">
            
                    
                    使用 bgcolor 进行背景着色
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="../annotations/8shape.html">
            
                <a href="../annotations/8shape.html">
            
                    
                    绘制形状、字符和箭头
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="../annotations/9custom.html">
            
                <a href="../annotations/9custom.html">
            
                    
                    定制 OHLC 柱和蜡烛
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../debugging/">
            
                <a href="../debugging/">
            
                    
                    调试
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../debugging/1introduction.html">
            
                <a href="../debugging/1introduction.html">
            
                    
                    指标注解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../debugging/2land.html">
            
                <a href="../debugging/2land.html">
            
                    
                    功能位置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../debugging/3num.html">
            
                <a href="../debugging/3num.html">
            
                    
                    显示数值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../debugging/4str.html">
            
                <a href="../debugging/4str.html">
            
                    
                    显示字符串
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="../debugging/5conditions.html">
            
                <a href="../debugging/5conditions.html">
            
                    
                    调试条件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.6" data-path="../debugging/6fn.html">
            
                <a href="../debugging/6fn.html">
            
                    
                    从内部函数调试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.7" data-path="../debugging/7for.html">
            
                <a href="../debugging/7for.html">
            
                    
                    从“for”循环内部调试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.8" data-path="../debugging/8tips.html">
            
                <a href="../debugging/8tips.html">
            
                    
                    提示
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../publishing/">
            
                <a href="../publishing/">
            
                    
                    发布脚本
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../publishing/1pvp.html">
            
                <a href="../publishing/1pvp.html">
            
                    
                    公共脚本与私有脚本
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../publishing/2mode.html">
            
                <a href="../publishing/2mode.html">
            
                    
                    发布模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../publishing/3ps.html">
            
                <a href="../publishing/3ps.html">
            
                    
                    如何发布脚本
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../publishing/4us.html">
            
                <a href="../publishing/4us.html">
            
                    
                    如何更新脚本
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../library/">
            
                <a href="../library/">
            
                    
                    公共库
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../library/1description.html">
            
                <a href="../library/1description.html">
            
                    
                    描述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../library/2copy.html">
            
                <a href="../library/2copy.html">
            
                    
                    将脚本从公共库复制到您的个人库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../library/3editing.html">
            
                <a href="../library/3editing.html">
            
                    
                    编辑来自公共库的脚本
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4" data-path="../library/4searching.html">
            
                <a href="../library/4searching.html">
            
                    
                    搜索脚本
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.5" data-path="../library/5video.html">
            
                <a href="../library/5video.html">
            
                    
                    教学视频
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../appendix/">
            
                <a href="../appendix/">
            
                    
                    附录
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../appendix/1migration.html">
            
                <a href="../appendix/1migration.html">
            
                    
                    Pine 第 3 版迁移指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../appendix/2how.html">
            
                <a href="../appendix/2how.html">
            
                    
                    操作指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../appendix/3err.html">
            
                <a href="../appendix/3err.html">
            
                    
                    Pine 的编译和执行错误
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../more/">
            
                <a href="../more/">
            
                    
                    我可以从哪里获得更多信息？
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本書使用 GitBook 釋出
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >绘图</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x7ED8;&#x56FE;">&#x7ED8;&#x56FE;</h1>
<hr>
<p>&#x4ECE; Pine v4 &#x5F00;&#x59CB;&#xFF0C;&#x6307;&#x6807;&#x548C;&#x7B56;&#x7565;&#x53EF;&#x4EE5;&#x5728;&#x56FE;&#x8868;&#x4E0A;&#x521B;&#x5EFA;&#x7ED8;&#x56FE;&#x5BF9;&#x8C61;&#x3002;&#x76EE;&#x524D;&#x652F;&#x6301;&#x4E09;&#x79CD;&#x7C7B;&#x578B;&#x7684;&#x7ED8;&#x56FE;&#xFF1A;&#x6807;&#x7B7E;&#x3001;&#x7EBF;&#x6761;&#x548C;&#x65B9;&#x6846;&#x3002;&#x5728;&#x4E0B;&#x9762;&#x7684;&#x56FE;&#x8868;&#x4E2D;&#xFF0C;&#x4F60;&#x4F1A;&#x53D1;&#x73B0;&#x6BCF;&#x79CD;&#x90FD;&#x6709;&#x4E00;&#x4E2A;&#x5B9E;&#x4F8B;&#xFF1A;</p>
<p><img src="../img/36draw/label_and_line_drawings.png" alt="&#x793A;&#x4F8B;&#x56FE;"></p>
<hr>
<blockquote>
<p>&#x6CE8;&#x610F;<br>&#x5728;TradingView &#x56FE;&#x8868;&#x4E0A;&#xFF0C;&#x4E00;&#x5957;&#x5B8C;&#x6574;&#x7684;&#x7ED8;&#x56FE;&#x5DE5;&#x5177;&#x5141;&#x8BB8;&#x7528;&#x6237;&#x4F7F;&#x7528;&#x9F20;&#x6807;&#x64CD;&#x4F5C;&#x6765;&#x521B;&#x5EFA;&#x548C;&#x4FEE;&#x6539;&#x7ED8;&#x56FE;&#x3002;&#x867D;&#x7136;&#x5B83;&#x4EEC;&#x53EF;&#x80FD;&#x770B;&#x8D77;&#x6765;&#x4E0E;&#x7528; Pine &#x4EE3;&#x7801;&#x521B;&#x5EFA;&#x7684;&#x7ED8;&#x56FE;&#x5BF9;&#x8C61;&#x76F8;&#x4F3C;&#xFF0C;&#x4F46;&#x5B83;&#x4EEC;&#x5728;&#x672C;&#x8D28;&#x4E0A;&#x662F;&#x4E0D;&#x540C;&#x7684;&#x5B9E;&#x4F53;&#x3002;&#x4F7F;&#x7528; Pine &#x4EE3;&#x7801;&#x521B;&#x5EFA;&#x7684;&#x7ED8;&#x56FE;&#x5BF9;&#x8C61;&#x4E0D;&#x80FD;&#x7528;&#x9F20;&#x6807;&#x64CD;&#x4F5C;&#x8FDB;&#x884C;&#x4FEE;&#x6539;&#x3002;</p>
</blockquote>
<hr>
<p>Pine v4 &#x4E2D;&#x7684;&#x7EBF;&#x6761;&#x3001;&#x6807;&#x7B7E;&#x548C;&#x6846;&#x56FE;&#x5141;&#x8BB8;&#x4F60;&#x521B;&#x5EFA;&#x5177;&#x6709;&#x66F4;&#x590D;&#x6742;&#x89C6;&#x89C9;&#x7EC4;&#x4EF6;&#x7684;&#x6307;&#x6807;&#xFF0C;&#x4F8B;&#x5982;&#xFF0C;&#x67A2;&#x8F74;&#x70B9;&#x3001;&#x652F;&#x6491;/&#x963B;&#x529B;&#x4F4D;&#x3001;&#x4E4B;&#x5B57;&#x7EBF;&#x3001;&#x5305;&#x542B;&#x52A8;&#x6001;&#x6587;&#x672C;&#x7684;&#x6807;&#x7B7E;&#x7B49;&#x3002;</p>
<p>&#x4E0E;&#x6307;&#x6807;&#x56FE;&#x76F8;&#x6BD4;&#xFF08;&#x56FE;&#x662F;&#x7528;&#x51FD;&#x6570; plot&#x3001;plotshape&#x3001;plotchar &#x521B;&#x5EFA;&#x7684;&#xFF09;&#xFF0C;&#x7ED8;&#x56FE;&#x5BF9;&#x8C61;&#x53EF;&#x4EE5;&#x5728;&#x5386;&#x53F2;&#x67F1;&#x4E0A;&#x4EE5;&#x53CA;&#x5728;&#x8FD8;&#x6CA1;&#x6709;&#x67F1;&#x5B58;&#x5728;&#x7684;&#x672A;&#x6765;&#x521B;&#x5EFA;&#x3002;</p>
<h2 id="&#x521B;&#x5EFA;&#x7ED8;&#x56FE;">&#x521B;&#x5EFA;&#x7ED8;&#x56FE;</h2>
<p>Pine &#x7ED8;&#x56FE;&#x5BF9;&#x8C61;&#x662F;&#x7528; label.new&#x3001;line.new &#x548C; box.new &#x51FD;&#x6570;&#x521B;&#x5EFA;&#x7684;&#x3002;&#x867D;&#x7136;&#x6BCF;&#x4E2A;&#x51FD;&#x6570;&#x6709;&#x5F88;&#x591A;&#x53C2;&#x6570;&#xFF0C;&#x4F46;&#x53EA;&#x6709;&#x5750;&#x6807;&#x662F;&#x5FC5;&#x987B;&#x7684;&#x3002;&#x8FD9;&#x662F;&#x4E00;&#x4E2A;&#x7528;&#x4E8E;&#x5728;&#x6BCF;&#x4E2A;&#x67F1;&#x4E0A;&#x521B;&#x5EFA;&#x6807;&#x7B7E;&#x7684;&#x4EE3;&#x7801;&#x4F8B;&#x5B50;&#x3002;</p>
<pre><code>//@version=4
study(&quot;My Script&quot;, overlay=true)
label.new(bar_index, high)
</code></pre><p><img src="../img/36draw/minimal_label.png" alt="&#x793A;&#x4F8B;&#x56FE;"></p>
<p>&#x6807;&#x7B7E;&#x7684;&#x521B;&#x5EFA;&#x53C2;&#x6570;&#x4E3A; x=bar_index&#xFF08;&#x5F53;&#x524D;&#x67F1;&#x7684;&#x7D22;&#x5F15;&#xFF0C;bar_index&#xFF09;&#x548C; y=high&#xFF08;&#x5F53;&#x524D;&#x6761;&#x5F62;&#x7684;&#x9AD8;&#x4EF7;&#xFF09;&#x3002;&#x5F53;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x67F1;&#x6253;&#x5F00;&#x65F6;&#xFF0C;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x6807;&#x7B7E;&#x5C31;&#x4F1A;&#x5728;&#x4E0A;&#x9762;&#x521B;&#x5EFA;&#x3002;&#x5728;&#x4EE5;&#x524D;&#x7684;&#x67F1;&#x4E0A;&#x521B;&#x5EFA;&#x7684;&#x6807;&#x7B7E;&#x5BF9;&#x8C61;&#x4F1A;&#x7559;&#x5728;&#x56FE;&#x8868;&#x4E0A;&#xFF0C;&#x76F4;&#x5230;&#x6307;&#x6807;&#x901A;&#x8FC7;&#x660E;&#x786E;&#x8C03;&#x7528; label.delete &#x51FD;&#x6570;&#x5C06;&#x5176;&#x5220;&#x9664;&#xFF0C;&#x6216;&#x8005;&#x76F4;&#x5230;&#x81EA;&#x52A8;&#x5783;&#x573E;&#x6536;&#x96C6;&#x7A0B;&#x5E8F;&#x5C06;&#x5176;&#x5220;&#x9664;&#x3002;</p>
<p>&#x4E0B;&#x9762;&#x662F;&#x540C;&#x4E00;&#x811A;&#x672C;&#x7684;&#x4FEE;&#x6539;&#x7248;&#xFF0C;&#x663E;&#x793A;&#x4E86;&#x7528;&#x4E8E;&#x521B;&#x5EFA;&#x6807;&#x7B7E;&#x7684; x &#x548C; y &#x5750;&#x6807;&#x503C;&#xFF1A;</p>
<pre><code>//@version=4
study(&quot;My Script&quot;, overlay=true)
label.new(bar_index, high, style=label.style_none,
          text=&quot;x=&quot; + tostring(bar_index) + &quot;\ny=&quot; + tostring(high))
</code></pre><p><img src="../img/36draw/minimal_label_with_x_y_coordinates.png" alt="&#x793A;&#x4F8B;&#x56FE;"></p>
<p>&#x5728;&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#x4E2D;&#xFF0C;&#x6807;&#x7B7E;&#x7684;&#x663E;&#x793A;&#x6CA1;&#x6709;&#x80CC;&#x666F;&#x7740;&#x8272;&#xFF08;&#x56E0;&#x4E3A;&#x53C2;&#x6570; style=label.style_none&#xFF09;&#xFF0C;&#x4F46;&#x6709;&#x52A8;&#x6001;&#x521B;&#x5EFA;&#x7684;&#x6587;&#x672C;&#xFF08;text=&quot;x=&quot; + tostring(bar_index) + &quot;\ny=&quot; + tostring(high)&#xFF09;&#xFF0C;&#x6253;&#x5370;&#x51FA;&#x6807;&#x7B7E;&#x5750;&#x6807;&#x3002;</p>
<p>&#x8FD9;&#x662F;&#x4E00;&#x4E2A;&#x5728;&#x56FE;&#x8868;&#x4E0A;&#x521B;&#x5EFA;&#x7EBF;&#x6761;&#x5BF9;&#x8C61;&#x7684;&#x4EE3;&#x7801;&#x4F8B;&#x5B50;:</p>
<pre><code>//@version=4
study(&quot;My Script&quot;, overlay=true)
line.new(x1=bar_index[1], y1=low[1], x2=bar_index, y2=high)
</code></pre><p><img src="../img/36draw/minimal_line.png" alt="&#x793A;&#x4F8B;&#x56FE;"></p>
<p>&#x8FD9;&#x662F;&#x4E00;&#x4E2A;&#x5728;&#x56FE;&#x8868;&#x4E0A;&#x521B;&#x5EFA;&#x65B9;&#x6846;&#x5BF9;&#x8C61;&#x7684;&#x4EE3;&#x7801;&#x5B9E;&#x4F8B;:</p>
<pre><code>//@version=4
study(&quot;My Script&quot;, overlay=true)
box.new(left=bar_index[1], top=low[1], right=bar_index, bottom=high)
</code></pre><p><img src="../img/36draw/minimal_box.png" alt="&#x793A;&#x4F8B;&#x56FE;"></p>
<h2 id="&#x8BA1;&#x7B97;&#x67F1;&#x66F4;&#x65B0;&#x540E;&#x7684;&#x7ED8;&#x5236;">&#x8BA1;&#x7B97;&#x67F1;&#x66F4;&#x65B0;&#x540E;&#x7684;&#x7ED8;&#x5236;</h2>
<p>&#x7ED8;&#x56FE;&#x5BF9;&#x8C61;&#x4F1A;&#x53D7;&#x5230;&#x63D0;&#x4EA4;&#x548C;&#x56DE;&#x6EDA;&#x52A8;&#x4F5C;&#x7684;&#x5F71;&#x54CD;&#xFF0C;&#x5F53;&#x811A;&#x672C;&#x5728;&#x5B9E;&#x65F6;&#x67F1;&#x6267;&#x884C;&#x6A21;&#x578B;&#x4E2D;&#x6267;&#x884C;&#x65F6;&#xFF0C;&#x4F1A;&#x5F71;&#x54CD;&#x811A;&#x672C;&#x7684;&#x884C;&#x4E3A;&#x3002;</p>
<p>&#x8FD9;&#x4E2A;&#x811A;&#x672C;&#x6F14;&#x793A;&#x4E86;&#x5728;&#x5B9E;&#x65F6;&#x680F;&#x4E2D;&#x8FD0;&#x884C;&#x65F6;&#x56DE;&#x6EDA;&#x7684;&#x6548;&#x679C;&#xFF1A;</p>
<pre><code>//@version=4
study(&quot;My Script&quot;, overlay=true)
label.new(bar_index, high)
</code></pre><p>&#x867D;&#x7136; label.new &#x5728;&#x811A;&#x672C;&#x7684;&#x6BCF;&#x6B21;&#x8FED;&#x4EE3;&#x4E2D;&#x90FD;&#x4F1A;&#x5728;&#x5B9E;&#x65F6;&#x67F1;&#x4E2D;&#x7684;&#x4EF7;&#x683C;&#x53D8;&#x5316;&#x65F6;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x6807;&#x7B7E;&#xFF0C;&#x4F46;&#x5728;&#x811A;&#x672C;&#x7684;&#x4E0A;&#x4E00;&#x6B21;&#x8FED;&#x4EE3;&#x4E2D;&#x521B;&#x5EFA;&#x7684;&#x6700;&#x65B0;&#x6807;&#x7B7E;&#x4E5F;&#x4F1A;&#x56E0;&#x4E3A;&#x4E0B;&#x4E00;&#x6B21;&#x8FED;&#x4EE3;&#x524D;&#x7684;&#x56DE;&#x6EDA;&#x800C;&#x81EA;&#x52A8;&#x5220;&#x9664;&#x3002;&#x53EA;&#x6709;&#x5728;&#x5B9E;&#x65F6;&#x67F1;&#x6536;&#x76D8;&#x524D;&#x521B;&#x5EFA;&#x7684;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x6807;&#x7B7E;&#x5C06;&#x88AB;&#x63D0;&#x4EA4;&#xFF0C;&#x624D;&#x5C06;&#x6301;&#x7EED;&#x5B58;&#x5728;&#x3002;</p>
<h2 id="&#x5750;&#x6807;">&#x5750;&#x6807;</h2>
<p>&#x7ED8;&#x56FE;&#x5BF9;&#x8C61;&#x6839;&#x636E; x &#x548C; y &#x5750;&#x6807;&#x5728;&#x56FE;&#x8868;&#x4E0A;&#x5B9A;&#x4F4D;&#xFF0C;&#x4F7F;&#x7528; 4 &#x4E2A;&#x53C2;&#x6570;&#x7684;&#x7EC4;&#x5408;&#xFF1A;x&#x3001;y&#x3001;xloc &#x548C; yloc&#x3002;xloc &#x7684;&#x503C;&#x51B3;&#x5B9A;&#x4E86; x &#x662F;&#x6301;&#x6709;&#x4E00;&#x4E2A;&#x67F1;&#x7D22;&#x5F15;&#x8FD8;&#x662F;&#x65F6;&#x95F4;&#x503C;&#x3002;&#x5F53; yloc=yloc.price &#x65F6;&#xFF0C;y &#x6301;&#x6709;&#x4EF7;&#x683C;&#x3002;&#x5F53; yloc &#x88AB;&#x8BBE;&#x7F6E;&#x4E3A; yloc.overbar &#x6216; yloc.belowbar &#x65F6;&#xFF0C;y &#x88AB;&#x5FFD;&#x7565;&#x3002;</p>
<p>&#x5982;&#x679C;&#x4E00;&#x4E2A;&#x7ED8;&#x56FE;&#x5BF9;&#x8C61;&#x4F7F;&#x7528; xloc.bar_index&#xFF0C;&#x90A3;&#x4E48; x &#x5750;&#x6807;&#x88AB;&#x89C6;&#x4E3A;&#x4E00;&#x4E2A;&#x7EDD;&#x5BF9;&#x7684;&#x67F1;&#x7D22;&#x5F15;&#x3002;&#x5F53;&#x524D;&#x67F1;&#x56FE;&#x7684;&#x67F1;&#x7D22;&#x5F15;&#x53EF;&#x4EE5;&#x4ECE;&#x5185;&#x7F6E;&#x53D8;&#x91CF; bar_index &#x83B7;&#x5F97;&#x3002;&#x4E4B;&#x524D;&#x7684;&#x67F1;&#x7D22;&#x5F15;&#x662F; bar_index[1]&#xFF0C;bar_index[2]&#xFF0C;&#x4EE5;&#x6B64;&#x7C7B;&#x63A8;&#x3002;xloc.bar_index &#x662F;&#x6807;&#x7B7E;&#x548C;&#x7EBF;&#x6761;&#x56FE;&#x7684; x-location &#x53C2;&#x6570;&#x7684;&#x9ED8;&#x8BA4;&#x503C;&#x3002;</p>
<p>&#x5982;&#x679C;&#x4E00;&#x4E2A;&#x7ED8;&#x56FE;&#x5BF9;&#x8C61;&#x4F7F;&#x7528; xloc.bar_time&#xFF0C;&#x90A3;&#x4E48; x &#x5750;&#x6807;&#x5C06;&#x88AB;&#x89C6;&#x4E3A; UNIX &#x65F6;&#x95F4;&#xFF0C;&#x5355;&#x4F4D;&#x662F;&#x6BEB;&#x79D2;&#x3002;&#x5F53;&#x524D;&#x67F1;&#x56FE;&#x7684;&#x5F00;&#x59CB;&#x65F6;&#x95F4;&#x53EF;&#x4EE5;&#x4ECE;&#x5185;&#x7F6E;&#x53D8;&#x91CF; time &#x4E2D;&#x83B7;&#x5F97;&#x3002;&#x4E4B;&#x524D;&#x7684;&#x67F1;&#x56FE;&#x7684;&#x65F6;&#x95F4;&#x662F; time[1]&#xFF0C;time[2]&#xFF0C;&#x4EE5;&#x6B64;&#x7C7B;&#x63A8;&#x3002;&#x65F6;&#x95F4;&#x4E5F;&#x53EF;&#x4EE5;&#x7528; timestamp &#x51FD;&#x6570;&#x8BBE;&#x7F6E;&#x4E3A;&#x4E00;&#x4E2A;&#x7EDD;&#x5BF9;&#x7684;&#x65F6;&#x95F4;&#x70B9;&#x3002;</p>
<p>xloc.bar_time &#x6A21;&#x5F0F;&#x53EF;&#x4EE5;&#x5728;&#x672A;&#x6765;&#x5C06;&#x7ED8;&#x56FE;&#x5BF9;&#x8C61;&#x653E;&#x7F6E;&#x5728;&#x5F53;&#x524D;&#x680F;&#x7684;&#x53F3;&#x4FA7;&#x3002;&#x6BD4;&#x5982;&#x8BF4;&#xFF1A;</p>
<pre><code>//@version=4
study(&quot;My Script&quot;, overlay=true)
dt = time - time[1]
if barstate.islast
    label.new(time + 3*dt, close, xloc=xloc.bar_time)
</code></pre><p><img src="../img/36draw/label_in_the_future.png" alt="&#x793A;&#x4F8B;&#x56FE;"></p>
<p>&#x8FD9;&#x6BB5;&#x4EE3;&#x7801;&#x5C06;&#x4E00;&#x4E2A;&#x6807;&#x7B7E;&#x5BF9;&#x8C61;&#x653E;&#x7F6E;&#x5728;&#x672A;&#x6765;&#x3002;X &#x7684;&#x5B9A;&#x4F4D;&#x903B;&#x8F91;&#x5BF9;&#x6807;&#x7B7E;&#x3001;&#x7EBF;&#x548C;&#x6846;&#x56FE;&#x7684;&#x4F5C;&#x7528;&#x662F;&#x76F8;&#x540C;&#x7684;&#x3002;</p>
<p>&#x76F8;&#x6BD4;&#x4E4B;&#x4E0B;&#xFF0C;y &#x7684;&#x5B9A;&#x4F4D;&#x903B;&#x8F91;&#x5BF9;&#x4E8E;&#x6807;&#x7B7E;&#x548C;&#x7EBF;&#x56FE;&#x6216;&#x6846;&#x56FE;&#x662F;&#x4E0D;&#x540C;&#x7684;&#x3002;Pine &#x7684;&#x7EBF;&#x56FE;&#x548C;&#x6846;&#x56FE;&#x603B;&#x662F;&#x4F7F;&#x7528; yloc.price&#xFF0C;&#x6240;&#x4EE5;&#x5B83;&#x4EEC;&#x7684; y &#x5750;&#x6807;&#x603B;&#x662F;&#x88AB;&#x5F53;&#x4F5C;&#x4E00;&#x4E2A;&#x7EDD;&#x5BF9;&#x4EF7;&#x683C;&#x503C;&#x3002;</p>
<p>&#x6807;&#x7B7E;&#x56FE;&#x6709;&#x989D;&#x5916;&#x7684; y-location &#x503C;&#xFF1A;yloc.overbar &#x548C; yloc.underbar&#x3002;&#x5F53;&#x5B83;&#x4EEC;&#x88AB;&#x4F7F;&#x7528;&#x65F6;&#xFF0C;y &#x53C2;&#x6570;&#x7684;&#x503C;&#x88AB;&#x5FFD;&#x7565;&#xFF0C;&#x7ED8;&#x56FE;&#x5BF9;&#x8C61;&#x88AB;&#x653E;&#x7F6E;&#x5728;&#x67F1;&#x56FE;&#x7684;&#x4E0A;&#x65B9;&#x6216;&#x4E0B;&#x65B9;&#x3002;</p>
<h2 id="&#x4FEE;&#x6539;&#x7ED8;&#x5236;">&#x4FEE;&#x6539;&#x7ED8;&#x5236;</h2>
<p>&#x7ED8;&#x56FE;&#x5BF9;&#x8C61;&#x53EF;&#x4EE5;&#x5728;&#x5176;&#x521B;&#x5EFA;&#x540E;&#x88AB;&#x4FEE;&#x6539;&#x3002;label.new&#x3001;line.new &#x548C; box.new &#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x5BF9;&#x521B;&#x5EFA;&#x7684;&#x7ED8;&#x56FE;&#x5BF9;&#x8C61;&#xFF08;&#x5206;&#x522B;&#x4E3A;&#x7CFB;&#x5217;&#x6807;&#x7B7E;&#x3001;&#x7CFB;&#x5217;&#x7EBF;&#x548C;&#x7CFB;&#x5217;&#x6846;&#x7684;&#x7C7B;&#x578B;&#xFF09;&#x7684;&#x5F15;&#x7528;&#x3002;&#x7136;&#x540E;&#xFF0C;&#x8FD9;&#x4E2A;&#x5F15;&#x7528;&#x53EF;&#x4EE5;&#x4F5C;&#x4E3A; label.set<em>*&#x3001;line.set</em><em> &#x6216; box.set_</em> &#x51FD;&#x6570;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#xFF0C;&#x7528;&#x4E8E;&#x4FEE;&#x6539;&#x7ED8;&#x56FE;&#x3002;&#x4F8B;&#x5982;&#xFF1A;</p>
<pre><code>//@version=4
study(&quot;My Script&quot;, overlay=true)
l = label.new(bar_index, na)
if close &gt;= open
    label.set_text(l, &quot;green&quot;)
    label.set_color(l, color.green)
    label.set_yloc(l, yloc.belowbar)
    label.set_style(l, label.style_label_up)
else
    label.set_text(l, &quot;red&quot;)
    label.set_color(l, color.red)
    label.set_yloc(l, yloc.abovebar)
    label.set_style(l, label.style_label_down)
</code></pre><p><img src="../img/36draw/label_changing_example.png" alt="&#x793A;&#x4F8B;&#x56FE;"></p>
<p>&#x8FD9;&#x4E2A;&#x7B80;&#x5355;&#x7684;&#x811A;&#x672C;&#x9996;&#x5148;&#x5728;&#x5F53;&#x524D;&#x67F1;&#x4E0A;&#x521B;&#x5EFA;&#x4E86;&#x4E00;&#x4E2A;&#x6807;&#x7B7E;&#xFF0C;&#x7136;&#x540E;&#x5728;&#x4E00;&#x4E2A;&#x53D8;&#x91CF; l &#x4E2D;&#x5199;&#x5165;&#x5BF9;&#x5B83;&#x7684;&#x5F15;&#x7528;&#x3002;&#x7136;&#x540E;&#xFF0C;&#x6839;&#x636E;&#x5F53;&#x524D;&#x67F1;&#x662F;&#x4E0A;&#x5347;&#x8FD8;&#x662F;&#x4E0B;&#x964D;&#xFF08;&#x6761;&#x4EF6;&#xFF1A; close &gt;= open&#xFF09;&#xFF0C;&#x4E00;&#x4E9B;&#x6807;&#x7B7E;&#x7684;&#x7ED8;&#x5236;&#x5C5E;&#x6027;&#x88AB;&#x4FEE;&#x6539;&#xFF1A;&#x6587;&#x672C;&#x3001;&#x989C;&#x8272;&#x3001;y &#x5750;&#x6807;&#x4F4D;&#x7F6E;&#xFF08;yloc&#xFF09;&#x548C;&#x6807;&#x7B7E;&#x6837;&#x5F0F;&#x3002;</p>
<p>&#x53EF;&#x80FD;&#x4F1A;&#x6CE8;&#x610F;&#x5230;&#xFF0C;&#x5728;&#x8C03;&#x7528; label.new &#x51FD;&#x6570;&#x65F6;&#xFF0C;na &#x88AB;&#x4F5C;&#x4E3A; y &#x53C2;&#x6570;&#x4F20;&#x9012;&#x3002;&#x539F;&#x56E0;&#x662F;&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#x7684;&#x6807;&#x7B7E;&#x4F7F;&#x7528;&#x4E86; yloc.underbar &#x6216; yloc.overbar &#x7684; y &#x5750;&#x6807;&#x4F4D;&#x7F6E;&#xFF0C;&#x8FD9;&#x4E0D;&#x9700;&#x8981;&#x4E00;&#x4E2A; y &#x503C;&#x3002;y &#x4EC5;&#x5F53;&#x6807;&#x7B7E;&#x4F7F;&#x7528; yloc.price &#x65F6;&#x624D;&#x9700;&#x8981;&#x6709;&#x9650;&#x503C;&#x3002;</p>
<p>&#x7528;&#x4E8E;&#x6807;&#x7B7E;&#x7ED8;&#x5236;&#x7684;&#x8BBE;&#x7F6E;&#x51FD;&#x6570;&#x6709;&#xFF1A;</p>
<ul>
<li>label.set_color &#x2014; &#x6539;&#x53D8;&#x6807;&#x7B7E;&#x7684;&#x989C;&#x8272;</li>
<li>label.set_size &#x2014; &#x6539;&#x53D8;&#x6807;&#x7B7E;&#x7684;&#x5927;&#x5C0F;</li>
<li>label.set_style &#x2014; &#x6539;&#x53D8;&#x6807;&#x7B7E;&#x7684;&#x6837;&#x5F0F;</li>
<li>label.set_text &#x2014; &#x66F4;&#x6539;&#x6807;&#x7B7E;&#x6587;&#x672C;</li>
<li>label.set_textcolor &#x2014; &#x6539;&#x53D8;&#x6587;&#x672C;&#x7684;&#x989C;&#x8272;</li>
<li>label.set_x &#x2014; &#x6539;&#x53D8;&#x6807;&#x7B7E;&#x7684; x &#x5750;&#x6807;</li>
<li>label.set_y &#x2014; &#x6539;&#x53D8;&#x6807;&#x7B7E;&#x7684; y &#x5750;&#x6807;</li>
<li>label.set_xy &#x2014; &#x6539;&#x53D8;&#x6807;&#x7B7E;&#x7684; x &#x548C; y &#x5750;&#x6807;</li>
<li>label.set_xloc &#x2014; &#x66F4;&#x6539;&#x6807;&#x7B7E;&#x7684; x &#x4F4D;&#x7F6E;</li>
<li>label.set_yloc &#x2014; &#x66F4;&#x6539;&#x6807;&#x7B7E;&#x7684; y &#x4F4D;&#x7F6E;</li>
<li>label.set_tooltip &#x2014; &#x66F4;&#x6539;&#x6807;&#x7B7E;&#x7684;&#x5DE5;&#x5177;&#x63D0;&#x793A;</li>
</ul>
<p>&#x53EF;&#x7528;&#x4E8E;&#x7EBF;&#x56FE;&#x7ED8;&#x5236;&#x7684;&#x8BBE;&#x7F6E;&#x51FD;&#x6570;&#x6709;&#xFF1A;</p>
<ul>
<li>line.set_color &#x2014; &#x6539;&#x53D8;&#x7EBF;&#x6761;&#x7684;&#x989C;&#x8272;</li>
<li>line.set_extend &#x2014; &#x66F4;&#x6539;&#x5C5E;&#x6027;&#xFF1A;<ul>
<li>extend.none - &#x7EBF;&#x6BB5;</li>
<li>extend.left / extend.right - &#x5C04;&#x7EBF;</li>
<li>extend.both - &#x76F4;&#x7EBF;</li>
</ul>
</li>
<li>line.set_style &#x2014; &#x6539;&#x53D8;&#x7EBF;&#x6761;&#x7684;&#x6837;&#x5F0F;</li>
<li>line.set_width &#x2014; &#x6539;&#x53D8;&#x7EBF;&#x5BBD;</li>
<li>line.set_xloc &#x2014; &#x66F4;&#x6539;&#x7EBF;&#x7684; x &#x4F4D;&#x7F6E;&#xFF08;x1 &#x548C; x2&#xFF09;</li>
<li>line.set_x1 &#x2014; &#x6539;&#x53D8;&#x7EBF;&#x7684; x1 &#x5750;&#x6807;</li>
<li>line.set_y1 &#x2014; &#x6539;&#x53D8;&#x7EBF;&#x7684; y1 &#x5750;&#x6807;</li>
<li>line.set_xy1 &#x2014; &#x6539;&#x53D8;&#x7EBF;&#x7684; x1 &#x548C; y1 &#x5750;&#x6807;</li>
<li>line.set_x2 &#x2014; &#x6539;&#x53D8;&#x7EBF;&#x7684; x2 &#x5750;&#x6807;</li>
<li>line.set_y2 &#x2014; &#x6539;&#x53D8;&#x7EBF;&#x7684; y2 &#x5750;&#x6807;</li>
<li>line.set_xy2 &#x2014; &#x540C;&#x65F6;&#x6539;&#x53D8;&#x7EBF;&#x7684; x2 &#x548C; y2 &#x5750;&#x6807;</li>
</ul>
<p>&#x53EF;&#x7528;&#x4E8E;&#x7BB1;&#x56FE;&#x7ED8;&#x5236;&#x7684;&#x8BBE;&#x7F6E;&#x51FD;&#x6570;&#x6709;&#xFF1A;</p>
<ul>
<li>box.set_border_color &#x2014; &#x6539;&#x53D8;&#x6846;&#x7684;&#x8FB9;&#x6846;&#x989C;&#x8272;</li>
<li>box.set_bgcolor &#x2014; &#x6539;&#x53D8;&#x76D2;&#x5B50;&#x7684;&#x80CC;&#x666F;&#x989C;&#x8272;</li>
<li>box.set_extend &#x2014; &#x66F4;&#x6539;&#x5C5E;&#x6027;&#xFF1A;<ul>
<li>extend.none - &#x6C34;&#x5E73;&#x8FB9;&#x6846;&#x4ECE;&#x5DE6;&#x8FB9;&#x6846;&#x5F00;&#x59CB;&#xFF0C;&#x5230;&#x53F3;&#x8FB9;&#x6846;&#x7ED3;&#x675F;</li>
<li>extend.left / extend.right - &#x6C34;&#x5E73;&#x8FB9;&#x6846;&#x65E0;&#x9650;&#x5EF6;&#x4F38;&#x5230;&#x6846;&#x7684;&#x5DE6;&#x4FA7;/&#x53F3;&#x4FA7;</li>
<li>extend.both - &#x6C34;&#x5E73;&#x8FB9;&#x754C;&#x5728;&#x4E24;&#x4FA7;&#x5EF6;&#x4F38;</li>
</ul>
</li>
<li>box.set_border_style &#x2014; &#x6539;&#x53D8;&#x6846;&#x7684;&#x8FB9;&#x6846;&#x6837;&#x5F0F;</li>
<li>box.set_border_width &#x2014; &#x6539;&#x53D8;&#x6846;&#x7684;&#x8FB9;&#x6846;&#x5BBD;&#x5EA6;</li>
<li>box.set_bottom &#x2014; &#x6539;&#x53D8;&#x76D2;&#x5B50;&#x7684;&#x5E95;&#x90E8;&#x5750;&#x6807;</li>
<li>box.set_right &#x2014; &#x6539;&#x53D8;&#x76D2;&#x5B50;&#x7684;&#x53F3;&#x5750;&#x6807;</li>
<li>box.set_rightbottom &#x2014; &#x540C;&#x65F6;&#x6539;&#x53D8;&#x76D2;&#x5B50;&#x7684;&#x53F3;&#x5750;&#x6807;&#x548C;&#x5E95;&#x5750;&#x6807;</li>
<li>box.set_top &#x2014; &#x6539;&#x53D8;&#x76D2;&#x5B50;&#x7684;&#x9876;&#x90E8;&#x5750;&#x6807;</li>
<li>box.set_left &#x2014; &#x6539;&#x53D8;&#x76D2;&#x5B50;&#x7684;&#x5DE6;&#x5750;&#x6807;</li>
<li>box.set_lefttop &#x2014; &#x540C;&#x65F6;&#x6539;&#x53D8;&#x76D2;&#x5B50;&#x7684;&#x5DE6;&#x5750;&#x6807;&#x548C;&#x4E0A;&#x5750;&#x6807;</li>
</ul>
<h2 id="&#x6807;&#x7B7E;&#x6837;&#x5F0F;">&#x6807;&#x7B7E;&#x6837;&#x5F0F;</h2>
<p>&#x53EF;&#x4EE5;&#x4F7F;&#x7528; label.new &#x6216; label.set_style &#x51FD;&#x6570;&#x5C06;&#x5404;&#x79CD;&#x6837;&#x5F0F;&#x5E94;&#x7528;&#x4E8E;&#x6807;&#x7B7E;&#xFF1A;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x6807;&#x7B7E;&#x6837;&#x5F0F;&#x540D;&#x79F0;</th>
<th style="text-align:left">&#x6807;&#x7B7E;</th>
<th style="text-align:left">&#x5E26;&#x6709;&#x6587;&#x5B57;&#x7684;&#x6807;&#x7B7E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">label.style_none</td>
<td style="text-align:left"></td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_none_t.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
</tr>
<tr>
<td style="text-align:left">label.style_xcross</td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_xcross.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_xcross_t.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
</tr>
<tr>
<td style="text-align:left">label.style_cross</td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_cross.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_cross_t.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
</tr>
<tr>
<td style="text-align:left">label.style_triangleup</td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_triangleup.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_triangleup_t.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
</tr>
<tr>
<td style="text-align:left">label.style_triangledown</td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_triangledown.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_triangledown_t.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
</tr>
<tr>
<td style="text-align:left">label.style_flag</td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_flag.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_flag_t.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
</tr>
<tr>
<td style="text-align:left">label.style_arrowup</td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_arrowup.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_arrowup_t.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
</tr>
<tr>
<td style="text-align:left">label.style_arrowdown</td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_arrowdown.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_arrowdown_t.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
</tr>
<tr>
<td style="text-align:left">label.style_label_up</td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_labelup.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_labelup_t.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
</tr>
<tr>
<td style="text-align:left">label.style_label_down</td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_labeldown.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_labeldown_t.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
</tr>
<tr>
<td style="text-align:left">label.style_square</td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_square.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_square_t.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
</tr>
<tr>
<td style="text-align:left">label.style_diamond</td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_diamond.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
<td style="text-align:left"><img src="../img/36draw/label/label.style_diamond_t.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
</tr>
</tbody>
</table>
<h2 id="&#x7EBF;&#x6761;&#x548C;&#x6846;&#x6837;&#x5F0F;">&#x7EBF;&#x6761;&#x548C;&#x6846;&#x6837;&#x5F0F;</h2>
<p>&#x53EF;&#x4EE5;&#x4F7F;&#x7528; line.new&#x3001;box.new&#x3001;line.set_style &#x6216; box.set_border_style &#x51FD;&#x6570;&#x5C06;&#x5404;&#x79CD;&#x6837;&#x5F0F;&#x5E94;&#x7528;&#x4E8E;&#x7EBF;&#x6761;&#xFF1A;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x7EBF;&#x578B;&#x540D;&#x79F0;</th>
<th style="text-align:left">&#x7EBF;</th>
<th style="text-align:left">&#x6846;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">line.style_solid</td>
<td style="text-align:left"><img src="../img/36draw/line/line.style_solid.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
<td style="text-align:left"><img src="../img/36draw/line/box.style_solid.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
</tr>
<tr>
<td style="text-align:left">line.style_dotted</td>
<td style="text-align:left"><img src="../img/36draw/line/line.style_dotted.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
<td style="text-align:left"><img src="../img/36draw/line/box.style_dotted.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
</tr>
<tr>
<td style="text-align:left">line.style_dashed</td>
<td style="text-align:left"><img src="../img/36draw/line/line.style_dashed.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
<td style="text-align:left"><img src="../img/36draw/line/box.style_dashed.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
</tr>
<tr>
<td style="text-align:left">line.style_arrow_left</td>
<td style="text-align:left"><img src="../img/36draw/line/line.style_arrow_left.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
<td style="text-align:left">&#x4E0D;&#x652F;&#x6301;</td>
</tr>
<tr>
<td style="text-align:left">line.style_arrow_right</td>
<td style="text-align:left"><img src="../img/36draw/line/line.style_arrow_right.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
<td style="text-align:left">&#x4E0D;&#x652F;&#x6301;</td>
</tr>
<tr>
<td style="text-align:left">line.style_arrow_both</td>
<td style="text-align:left"><img src="../img/36draw/line/line.style_arrow_both.png" alt="&#x793A;&#x4F8B;&#x56FE;"></td>
<td style="text-align:left">&#x4E0D;&#x652F;&#x6301;</td>
</tr>
</tbody>
</table>
<h2 id="&#x5220;&#x9664;&#x7ED8;&#x5236;">&#x5220;&#x9664;&#x7ED8;&#x5236;</h2>
<p>label.delete&#x3001;line.delete &#x548C; box.delete &#x51FD;&#x6570;&#x53EF;&#x4EE5;&#x4ECE;&#x56FE;&#x8868;&#x4E2D;&#x5220;&#x9664;&#x6807;&#x7B7E;&#x3001;&#x7EBF;&#x6216;&#x6846;&#x7684;&#x7ED8;&#x5236;&#x5BF9;&#x8C61;&#x3002;</p>
<p>&#x4E0B;&#x9762;&#x662F; Pine &#x7684;&#x4EE3;&#x7801;&#xFF0C;&#x5B83;&#x53EA;&#x4FDD;&#x7559;&#x4E86;&#x5F53;&#x524D;&#x6761;&#x5F62;&#x56FE;&#x4E0A;&#x7684;&#x4E00;&#x4E2A;&#x6807;&#x7B7E;&#x7ED8;&#x5236;&#x5BF9;&#x8C61;&#xFF0C;&#x5220;&#x9664;&#x4E86;&#x65E7;&#x7684;&#x6807;&#x7B7E;&#xFF1A;</p>
<pre><code>//@version=4
study(&quot;Last Bar Close 1&quot;, overlay=true)

c = close &gt;= open ? color.lime : color.red
l = label.new(bar_index, na,
  text=tostring(close), color=c,
  style=label.style_label_down, yloc=yloc.abovebar)

label.delete(l[1])
</code></pre><p><img src="../img/36draw/Last_Bar_Close_1.png" alt="&#x793A;&#x4F8B;&#x56FE;"></p>
<p>&#x5728;&quot;Last Bar Close 1&quot;&#x6307;&#x6807;&#x7684;&#x6BCF;&#x4E00;&#x4E2A;&#x67F1;&#x7684;&#x66F4;&#x65B0;&#x4E2D;&#xFF0C;&#x90FD;&#x4F1A;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x6807;&#x7B7E;&#x5BF9;&#x8C61;&#x5E76;&#x5199;&#x5165;&#x53D8;&#x91CF; l &#x4E2D;&#x3002;&#x7136;&#x540E;&#x524D;&#x4E00;&#x4E2A;&#x6807;&#x7B7E;&#x88AB;&#x4F20;&#x9012;&#x7ED9; label.delete &#x51FD;&#x6570;&#x6765;&#x5220;&#x9664;&#x5B83;&#x3002;</p>
<p>&#x5982;&#x679C; na &#x503C;&#x7528;&#x4F5C; id&#xFF0C;&#x5219;&#x51FD;&#x6570; label.delete &#x548C; line.delete &#x4EC0;&#x4E48;&#x90FD;&#x4E0D;&#x505A;&#xFF0C;&#x8FD9;&#x4F7F;&#x5F97;&#x4EE5;&#x4E0B;&#x4EE3;&#x7801;&#x53D8;&#x5F97;&#x4E0D;&#x5FC5;&#x8981;&#xFF1A;</p>
<pre><code>if not na(l[1])
    label.delete(l[1])
</code></pre><p>&#x524D;&#x9762;&#x7684;&#x811A;&#x672C;&#x7684;&#x884C;&#x4E3A;&#x53EF;&#x4EE5;&#x7528;&#x53E6;&#x4E00;&#x79CD;&#x65B9;&#x6CD5;&#x6765;&#x590D;&#x73B0;&#xFF1A;</p>
<pre><code>//@version=4
study(&quot;Last Bar Close 2&quot;, overlay=true)

var label l = na
label.delete(l)
c = close &gt;= open ? color.lime : color.red
l := label.new(bar_index, na,
  text=tostring(close), color=c,
  style=label.style_label_down, yloc=yloc.abovebar)
</code></pre><p>&#x5F53;&#x6307;&#x6807;&quot;Last Bar Close 2 &quot;&#x5F97;&#x5230;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x67F1;&#x66F4;&#x65B0;&#x65F6;&#xFF0C;&#x53D8;&#x91CF; l &#x4ECD;&#x7136;&#x5F15;&#x7528;&#x5728;&#x4E0A;&#x4E00;&#x67F1;&#x521B;&#x5EFA;&#x7684;&#x65E7;&#x6807;&#x7B7E;&#x5BF9;&#x8C61;&#x3002;&#x8FD9;&#x4E2A;&#x6807;&#x7B7E;&#x901A;&#x8FC7;&#x8C03;&#x7528; label.delete(l) &#x88AB;&#x5220;&#x9664;&#x3002;&#x7136;&#x540E;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x6807;&#x7B7E;&#xFF0C;&#x5E76;&#x5C06;&#x5176; ID &#x4FDD;&#x5B58;&#x5230; l &#x4E2D;&#x3002;&#x4F7F;&#x7528;&#x8FD9;&#x79CD;&#x65B9;&#x6CD5;&#x5C31;&#x4E0D;&#x9700;&#x8981;&#x4F7F;&#x7528; [] &#x64CD;&#x4F5C;&#x7B26;&#x3002;</p>
<p>&#x6CE8;&#x610F;&#x65B0;&#x7248;&#x672C; Pine Script v4 &#x4E2D; var &#x5173;&#x952E;&#x5B57;&#x7684;&#x4F7F;&#x7528;&#x3002;&#x5982;&#x679C;&#x4E0D;&#x662F;&#x56E0;&#x4E3A; l &#x53EA;&#x88AB;&#x521D;&#x59CB;&#x5316;&#x4E86;&#x4E00;&#x6B21;&#xFF0C; label.delete(l) &#x5C06;&#x6CA1;&#x6709;&#x5BF9;&#x8C61;&#x53EF;&#x4EE5;&#x5220;&#x9664;&#x3002;</p>
<p>&#x8FD8;&#x6709;&#x4E00;&#x79CD;&#x65B9;&#x6CD5;&#x53EF;&#x4EE5;&#x8FBE;&#x5230;&#x4E0E;&#x524D;&#x9762;&#x4E24;&#x4E2A;&#x811A;&#x672C;&#x76F8;&#x540C;&#x7684;&#x76EE;&#x7684;&#xFF0C;&#x8FD9;&#x6B21;&#x662F;&#x901A;&#x8FC7;&#x4FEE;&#x6539;&#x6807;&#x7B7E;&#x800C;&#x4E0D;&#x662F;&#x5220;&#x9664;&#x5B83;:</p>
<pre><code>//@version=4
study(&quot;Last Bar Close 3&quot;, overlay=true)

var label l = label.new(bar_index, na,
  style=label.style_label_down, yloc=yloc.abovebar)

c = close &gt;= open ? color.lime : color.red
label.set_color(l, c)
label.set_text(l, tostring(close))
label.set_x(l, bar_index)
</code></pre><p>&#x91CD;&#x7533;&#x4E00;&#x6B21;&#xFF0C;&#x65B0;&#x7248;&#x672C;&#x4E2D; var &#x5173;&#x952E;&#x5B57;&#x7684;&#x4F7F;&#x7528;&#x662F;&#x81F3;&#x5173;&#x91CD;&#x8981;&#x7684;&#x3002;&#x5B83;&#x4F7F; label.new &#x7684;&#x8C03;&#x7528;&#x53EA;&#x88AB;&#x6267;&#x884C;&#x4E00;&#x6B21;&#xFF0C;&#x5728;&#x7B2C;&#x4E00;&#x4E2A;&#x5386;&#x53F2;&#x67F1;&#x4E0A;&#x3002;</p>
<h2 id="&#x7ECF;&#x5178;&#x6307;&#x6807;&#x793A;&#x4F8B;">&#x7ECF;&#x5178;&#x6307;&#x6807;&#x793A;&#x4F8B;</h2>
<h3 id="&#x6807;&#x51C6;&#x67A2;&#x8F74;&#x70B9;">&#x6807;&#x51C6;&#x67A2;&#x8F74;&#x70B9;</h3>
<p><img src="../img/36draw/drawings_pivot_points_std.png" alt="&#x793A;&#x4F8B;&#x56FE;"></p>
<pre><code>//@version=4
study(&quot;Pivot Points Standard&quot;, overlay=true)
higherTF = input(&quot;D&quot;, type=input.resolution)
prevCloseHTF = security(syminfo.tickerid, higherTF, close[1], lookahead=true)
prevOpenHTF = security(syminfo.tickerid, higherTF, open[1], lookahead=true)
prevHighHTF = security(syminfo.tickerid, higherTF, high[1], lookahead=true)
prevLowHTF = security(syminfo.tickerid, higherTF, low[1], lookahead=true)

pLevel = (prevHighHTF + prevLowHTF + prevCloseHTF) / 3
r1Level = pLevel * 2 - prevLowHTF
s1Level = pLevel * 2 - prevHighHTF

var line r1Line = na
var line pLine = na
var line s1Line = na

if pLevel[1] != pLevel
    line.set_x2(r1Line, bar_index)
    line.set_x2(pLine, bar_index)
    line.set_x2(s1Line, bar_index)
    line.set_extend(r1Line, extend.none)
    line.set_extend(pLine, extend.none)
    line.set_extend(s1Line, extend.none)
    r1Line := line.new(bar_index, r1Level, bar_index, r1Level, extend=extend.right)
    pLine := line.new(bar_index, pLevel, bar_index, pLevel, width=3, extend=extend.right)
    s1Line := line.new(bar_index, s1Level, bar_index, s1Level, extend=extend.right)
    label.new(bar_index, r1Level, &quot;R1&quot;, style=label.style_none)
    label.new(bar_index, pLevel, &quot;P&quot;, style=label.style_none)
    label.new(bar_index, s1Level, &quot;S1&quot;, style=label.style_none)

if not na(pLine) and line.get_x2(pLine) != bar_index
    line.set_x2(r1Line, bar_index)
    line.set_x2(pLine, bar_index)
    line.set_x2(s1Line, bar_index)
</code></pre><h3 id="&#x9AD8;&#x4F4E;&#x67A2;&#x8F74;&#x70B9;">&#x9AD8;/&#x4F4E;&#x67A2;&#x8F74;&#x70B9;</h3>
<p><img src="../img/36draw/drawings_pivot_points_hl.png" alt="&#x793A;&#x4F8B;&#x56FE;"></p>
<pre><code>//@version=4
study(&quot;Pivot Points High Low&quot;, shorttitle=&quot;Pivots HL&quot;, overlay=true)

lenH = input(title=&quot;Length High&quot;, type=input.integer, defval=10, minval=1)
lenL = input(title=&quot;Length Low&quot;, type=input.integer, defval=10, minval=1)

fun(src, len, isHigh, _style, _yloc, _color) =&gt;
    p = nz(src[len])
    isFound = true
    for i = 0 to len - 1
        if isHigh and src[i] &gt; p
            isFound := false

        if not isHigh and src[i] &lt; p
            isFound := false

    for i = len + 1 to 2 * len
        if isHigh and src[i] &gt;= p
            isFound := false

        if not isHigh and src[i] &lt;= p
            isFound := false

    if isFound
        label.new(bar_index[len], p, tostring(p), style=_style, yloc=_yloc, color=_color)

fun(high, lenH, true, label.style_label_down, yloc.abovebar, color.lime)
fun(low, lenL, false, label.style_label_up, yloc.belowbar, color.red)
</code></pre><h3 id="&#x7EBF;&#x6027;&#x56DE;&#x5F52;">&#x7EBF;&#x6027;&#x56DE;&#x5F52;</h3>
<p><img src="../img/36draw/drawings_linear_regression.png" alt="&#x793A;&#x4F8B;&#x56FE;"></p>
<pre><code>//@version=4
study(&quot;Linear Regression&quot;, shorttitle=&quot;LinReg&quot;, overlay=true)

upperMult = input(title=&quot;Upper Deviation&quot;, defval=2)
lowerMult = input(title=&quot;Lower Deviation&quot;, defval=-2)

useUpperDev = input(title=&quot;Use Upper Deviation&quot;, defval=true)
useLowerDev = input(title=&quot;Use Lower Deviation&quot;, defval=true)
showPearson = input(title=&quot;Show Pearson&apos;s R&quot;, defval=true)
extendLines = input(title=&quot;Extend Lines&quot;, defval=false)

len = input(title=&quot;Count&quot;, defval=100)
src = input(title=&quot;Source&quot;, defval=close)

extend = extendLines ? extend.right : extend.none

calcSlope(src, len) =&gt;
    if not barstate.islast or len &lt;= 1
        [float(na), float(na), float(na)]
    else
        sumX = 0.0
        sumY = 0.0
        sumXSqr = 0.0
        sumXY = 0.0
        for i = 0 to len - 1
            val = src[i]
            per = i + 1.0
            sumX := sumX + per
            sumY := sumY + val
            sumXSqr := sumXSqr + per * per
            sumXY := sumXY + val * per
        slope = (len * sumXY - sumX * sumY) / (len * sumXSqr - sumX * sumX)
        average = sumY / len
        intercept = average - slope * sumX / len + slope
        [slope, average, intercept]

[s, a, i] = calcSlope(src, len)

startPrice = i + s * (len - 1)
endPrice = i
var line baseLine = na

if na(baseLine) and not na(startPrice)
    baseLine := line.new(bar_index - len + 1, startPrice, bar_index, endPrice, width=1, extend=extend, color=color.red)
else
    line.set_xy1(baseLine, bar_index - len + 1, startPrice)
    line.set_xy2(baseLine, bar_index, endPrice)
    na

calcDev(src, len, slope, average, intercept) =&gt;
    upDev = 0.0
    dnDev = 0.0
    stdDevAcc = 0.0
    dsxx = 0.0
    dsyy = 0.0
    dsxy = 0.0

    periods = len - 1

    daY = intercept + (slope * periods) / 2
    val = intercept

    for i = 0 to periods
        price = high[i] - val
        if (price &gt; upDev)
            upDev := price

        price := val - low[i]
        if (price &gt; dnDev)
            dnDev := price

        price := src[i]
        dxt = price - average
        dyt = val - daY

        price := price - val
        stdDevAcc := stdDevAcc + price * price
        dsxx := dsxx + dxt * dxt
        dsyy := dsyy + dyt * dyt
        dsxy := dsxy + dxt * dyt
        val := val + slope

    stdDev = sqrt(stdDevAcc / (periods == 0 ? 1 : periods))
    pearsonR = dsxx == 0 or dsyy == 0 ? 0 : dsxy / sqrt(dsxx * dsyy)
    [stdDev, pearsonR, upDev, dnDev]

[stdDev, pearsonR, upDev, dnDev] = calcDev(src, len, s, a, i)

upperStartPrice = startPrice + (useUpperDev ? upperMult * stdDev : upDev)
upperEndPrice = endPrice + (useUpperDev ? upperMult * stdDev : upDev)
var line upper = na

lowerStartPrice = startPrice + (useLowerDev ? lowerMult * stdDev : -dnDev)
lowerEndPrice = endPrice + (useLowerDev ? lowerMult * stdDev : -dnDev)
var line lower = na

if na(upper) and not na(upperStartPrice)
    upper := line.new(bar_index - len + 1, upperStartPrice, bar_index, upperEndPrice, width=1, extend=extend, color=#0000ff)
else
    line.set_xy1(upper, bar_index - len + 1, upperStartPrice)
    line.set_xy2(upper, bar_index, upperEndPrice)
    na

if na(lower) and not na(lowerStartPrice)
    lower := line.new(bar_index - len + 1, lowerStartPrice, bar_index, lowerEndPrice, width=1, extend=extend, color=#0000ff)
else
    line.set_xy1(lower, bar_index - len + 1, lowerStartPrice)
    line.set_xy2(lower, bar_index, lowerEndPrice)
    na

// Pearson&apos;s R
var label r = na
transparent = color.new(color.white, 100)
label.delete(r[1])
if showPearson and not na(pearsonR)
    r := label.new(bar_index - len + 1, lowerStartPrice, tostring(pearsonR, &quot;#.################&quot;), color=transparent, textcolor=#0000ff, size=size.normal, style=label.style_label_up)
</code></pre><h3 id="&#x4E4B;&#x5B57;&#x5F62;">&#x4E4B;&#x5B57;&#x5F62;</h3>
<p><img src="../img/36draw/drawings_zig_zag.png" alt="&#x793A;&#x4F8B;&#x56FE;"></p>
<pre><code>//@version=4
study(&quot;Zig Zag&quot;, overlay=true)

dev_threshold = input(title=&quot;Deviation (%)&quot;, type=input.float, defval=5, minval=1, maxval=100)
depth = input(title=&quot;Depth&quot;, type=input.integer, defval=10, minval=1)

pivots(src, length, isHigh) =&gt;
    p = nz(src[length])

    if length == 0
        [bar_index, p]
    else
        isFound = true
        for i = 0 to length - 1
            if isHigh and src[i] &gt; p
                isFound := false
            if not isHigh and src[i] &lt; p
                isFound := false

        for i = length + 1 to 2 * length
            if isHigh and src[i] &gt;= p
                isFound := false
            if not isHigh and src[i] &lt;= p
                isFound := false

        if isFound and length * 2 &lt;= bar_index
            [bar_index[length], p]
        else
            [int(na), float(na)]

[iH, pH] = pivots(high, floor(depth / 2), true)
[iL, pL] = pivots(low, floor(depth / 2), false)

calc_dev(base_price, price) =&gt;
    100 * (price - base_price) / base_price

var line lineLast = na
var int iLast = 0
var float pLast = 0
var bool isHighLast = true // otherwise the last pivot is a low pivot
var int linesCount = 0

pivotFound(dev, isHigh, index, price) =&gt;
    if isHighLast == isHigh and not na(lineLast)
        // same direction
        if isHighLast ? price &gt; pLast : price &lt; pLast
            if linesCount &lt;= 1
                line.set_xy1(lineLast, index, price)
            line.set_xy2(lineLast, index, price)
            [lineLast, isHighLast, false]
        else
            [line(na), bool(na), false]
    else // reverse the direction (or create the very first line)
        if na(lineLast)
            id = line.new(index, price, index, price, color=color.red, width=2)
            [id, isHigh, true]
        else
            // price move is significant
            if abs(dev) &gt;= dev_threshold
                id = line.new(iLast, pLast, index, price, color=color.red, width=2)
                [id, isHigh, true]
            else
                [line(na), bool(na), false]

if not na(iH) and not na(iL) and iH == iL
    dev1 = calc_dev(pLast, pH)
    [id2, isHigh2, isNew2] = pivotFound(dev1, true, iH, pH)
    if isNew2
        linesCount := linesCount + 1
    if not na(id2)
        lineLast := id2
        isHighLast := isHigh2
        iLast := iH
        pLast := pH

    dev2 = calc_dev(pLast, pL)
    [id1, isHigh1, isNew1] = pivotFound(dev2, false, iL, pL)
    if isNew1
        linesCount := linesCount + 1
    if not na(id1)
        lineLast := id1
        isHighLast := isHigh1
        iLast := iL
        pLast := pL

else
    if not na(iH)
        dev1 = calc_dev(pLast, pH)
        [id, isHigh, isNew] = pivotFound(dev1, true, iH, pH)
        if isNew
            linesCount := linesCount + 1
        if not na(id)
            lineLast := id
            isHighLast := isHigh
            iLast := iH
            pLast := pH
    else
        if not na(iL)
            dev2 = calc_dev(pLast, pL)
            [id, isHigh, isNew] = pivotFound(dev2, false, iL, pL)
            if isNew
                linesCount := linesCount + 1
            if not na(id)
                lineLast := id
                isHighLast := isHigh
                iLast := iL
                pLast := pL
</code></pre><h2 id="&#x9650;&#x5236;">&#x9650;&#x5236;</h2>
<h3 id="&#x7ED8;&#x5236;&#x6570;&#x91CF;&#x4E0A;&#x9650;">&#x7ED8;&#x5236;&#x6570;&#x91CF;&#x4E0A;&#x9650;</h3>
<p>&#x7ED8;&#x56FE;&#x5BF9;&#x8C61;&#x4F1A;&#x6D88;&#x8017;&#x670D;&#x52A1;&#x5668;&#x8D44;&#x6E90;&#xFF0C;&#x8FD9;&#x5C31;&#x662F;&#x4E3A;&#x4EC0;&#x4E48;&#x6BCF;&#x4E2A;&#x6307;&#x6807;&#x6216;&#x7B56;&#x7565;&#x7684;&#x7ED8;&#x56FE;&#x603B;&#x6570;&#x6709;&#x4E00;&#x4E2A;&#x9650;&#x5236;&#x3002;&#x5F53;&#x521B;&#x5EFA;&#x592A;&#x591A;&#x7684;&#x7ED8;&#x56FE;&#x65F6;&#xFF0C;&#x65E7;&#x7684;&#x7ED8;&#x56FE;&#x4F1A;&#x88AB; Pine &#x8FD0;&#x884C;&#x65F6;&#x81EA;&#x52A8;&#x5220;&#x9664;&#xFF0C;&#x8FD9;&#x4E2A;&#x8FC7;&#x7A0B;&#x88AB;&#x79F0;&#x4E3A;&#x5783;&#x573E;&#x56DE;&#x6536;&#x3002;</p>
<p>&#x8FD9;&#x6BB5;&#x4EE3;&#x7801;&#x5728;&#x6BCF;&#x4E2A;&#x67F1;&#x5B50;&#x4E0A;&#x90FD;&#x521B;&#x5EFA;&#x4E86;&#x4E00;&#x4E2A;&#x7ED8;&#x5236;&#xFF1A;</p>
<pre><code>//@version=4
study(&quot;My Script&quot;, overlay=true)
label.new(bar_index, high)
</code></pre><p>&#x5411;&#x5DE6;&#x6EDA;&#x52A8;&#x56FE;&#x8868;&#xFF0C;&#x5C31;&#x4F1A;&#x53D1;&#x73B0;&#x5728;&#x5927;&#x7EA6; 50 &#x4E2A;&#x67F1;&#x4E4B;&#x540E;&#x5C31;&#x6CA1;&#x6709;&#x7ED8;&#x5236;&#x4E86;&#x3002;</p>
<p><img src="../img/36draw/drawings_total_number_limit.png" alt="&#x793A;&#x4F8B;&#x56FE;"></p>
<p>&#x4F60;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x6307;&#x6807;&#x548C;&#x7B56;&#x7565;&#x51FD;&#x6570;&#x7684; max_lines_count&#x3001;max_labels_count &#x6216; max_boxes_count &#x53C2;&#x6570;&#xFF0C;&#x5C06;&#x7ED8;&#x56FE;&#x9650;&#x5236;&#x6539;&#x4E3A; 1 - 500 &#x8303;&#x56F4;&#x5185;&#x7684;&#x6570;&#x503C;&#x3002;</p>
<pre><code>//@version=4
study(&quot;My Script&quot;, overlay=true, max_labels_count=100)
label.new(bar_index, high)
</code></pre><p><img src="../img/36draw/drawings_with_max_labels_count.png" alt="&#x793A;&#x4F8B;&#x56FE;"></p>
<h3 id="&#x989D;&#x5916;&#x7684;&#x4EA4;&#x6613;&#x5BF9;">&#x989D;&#x5916;&#x7684;&#x4EA4;&#x6613;&#x5BF9;</h3>
<p>Pine &#x4EE3;&#x7801;&#x6709;&#x65F6;&#x4F1A;&#x4F7F;&#x7528;&#x989D;&#x5916;&#x7684;&#x4EA4;&#x6613;&#x5BF9;&#x6216;&#x65F6;&#x95F4;&#x7EA7;&#x522B;&#x4E0E; security &#x51FD;&#x6570;&#x3002;&#x7ED8;&#x56FE;&#x51FD;&#x6570;&#x53EA;&#x80FD;&#x5728;&#x4E3B;&#x7B26;&#x53F7;&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x4E2D;&#x4F7F;&#x7528;&#x3002;</p>
<h3 id="&#x7528;-maxbarsback-&#x8BBE;&#x7F6E;&#x65F6;&#x95F4;">&#x7528; max_bars_back &#x8BBE;&#x7F6E;&#x65F6;&#x95F4;</h3>
<p>&#x5C06; barstate.isrealtime &#x4E0E;&#x7ED8;&#x56FE;&#x7ED3;&#x5408;&#x4F7F;&#x7528;&#xFF0C;&#x6709;&#x65F6;&#x4F1A;&#x4EA7;&#x751F;&#x610F;&#x60F3;&#x4E0D;&#x5230;&#x7684;&#x7ED3;&#x679C;&#x3002;&#x4F8B;&#x5982;&#xFF0C;&#x8FD9;&#x6BB5;&#x4EE3;&#x7801;&#x7684;&#x610F;&#x56FE;&#x662F;&#x5FFD;&#x7565;&#x6240;&#x6709;&#x7684;&#x5386;&#x53F2;&#x67F1;&#x56FE;&#xFF0C;&#x5728;&#x5B9E;&#x65F6;&#x67F1;&#x56FE;&#x4E0A;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x6807;&#x7B7E;&#xFF1A;</p>
<pre><code>//@version=4
study(&quot;My Script&quot;, overlay=true)

if barstate.isrealtime
    label.new(bar_index[10], na, text=&quot;Label&quot;, yloc=yloc.abovebar)
</code></pre><p>&#x7136;&#x800C;&#xFF0C;&#x5B83;&#x5728;&#x8FD0;&#x884C;&#x65F6;&#x5C06;&#x4F1A;&#x5931;&#x8D25;&#x3002;&#x51FA;&#x9519;&#x7684;&#x539F;&#x56E0;&#x662F; Pine &#x65E0;&#x6CD5;&#x786E;&#x5B9A; time &#x7ED8;&#x56FE;&#x7684;&#x5386;&#x53F2;&#x503C;&#x7684;&#x7F13;&#x51B2;&#x533A;&#x5927;&#x5C0F;&#xFF0C;&#x5C3D;&#x7BA1;&#x4EE3;&#x7801;&#x4E2D;&#x6CA1;&#x6709;&#x63D0;&#x5230; time &#x5185;&#x7F6E;&#x53D8;&#x91CF;&#x3002;&#x8FD9;&#x662F;&#x7531;&#x4E8E;&#x5185;&#x7F6E;&#x53D8;&#x91CF; bar_index &#x5728;&#x5176;&#x5185;&#x90E8;&#x5DE5;&#x4F5C;&#x4E2D;&#x4F7F;&#x7528;&#x4E86;time series&#x3002;&#x8BBF;&#x95EE; 10 &#x4E2A;&#x67F1;&#x72B6;&#x7D22;&#x5F15;&#x7684;&#x503C;&#x9700;&#x8981; time series &#x7684;&#x5386;&#x53F2;&#x7F13;&#x51B2;&#x533A;&#x5927;&#x5C0F;&#x4E3A; 10 &#x6216;&#x66F4;&#x5927;&#x3002;</p>
<p>&#x5728; Pine &#x4E2D;&#xFF0C;&#x6709;&#x4E00;&#x79CD;&#x673A;&#x5236;&#x53EF;&#x4EE5;&#x5728;&#x5927;&#x591A;&#x6570;&#x60C5;&#x51B5;&#x4E0B;&#x81EA;&#x52A8;&#x68C0;&#x6D4B;&#x6240;&#x9700;&#x7684;&#x5386;&#x53F2;&#x7F13;&#x51B2;&#x533A;&#x5927;&#x5C0F;&#x3002;&#x81EA;&#x52A8;&#x68C0;&#x6D4B;&#x7684;&#x4F5C;&#x7528;&#x662F;&#x8BA9; Pine &#x4EE3;&#x7801;&#x5728;&#x6709;&#x9650;&#x7684;&#x65F6;&#x95F4;&#x5185;&#x8BBF;&#x95EE;&#x4EFB;&#x610F;&#x6570;&#x91CF;&#x7684;&#x5386;&#x53F2;&#x503C;&#x3002;&#x5728;&#x8FD9;&#x4E2A;&#x811A;&#x672C;&#x4E2D;&#xFF0C;&#x5982;&#x679C; barstate.isrealtime &#x6761;&#x4EF6;&#x963B;&#x6B62;&#x4E86;&#x4EFB;&#x4F55;&#x8FD9;&#x79CD;&#x8BBF;&#x95EE;&#x7684;&#x53D1;&#x751F;&#xFF0C;&#x6240;&#x4EE5;&#x65E0;&#x6CD5;&#x63A8;&#x65AD;&#x51FA;&#x6240;&#x9700;&#x7684;&#x5386;&#x53F2;&#x7F13;&#x51B2;&#x533A;&#x5927;&#x5C0F;&#xFF0C;&#x4EE3;&#x7801;&#x5C31;&#x4F1A;&#x5931;&#x8D25;&#x3002;</p>
<p>&#x89E3;&#x51B3;&#x8FD9;&#x4E2A;&#x96BE;&#x9898;&#x7684;&#x65B9;&#x6CD5;&#x662F;&#x4F7F;&#x7528; max_bars_back &#x51FD;&#x6570;&#x6765;&#x660E;&#x786E;&#x8BBE;&#x7F6E; time series &#x7684;&#x5386;&#x53F2;&#x7F13;&#x51B2;&#x533A;&#x5927;&#x5C0F;&#x3002;</p>
<pre><code>//@version=4
study(&quot;My Script&quot;, overlay=true)

max_bars_back(time, 10)

if barstate.isrealtime
    label.new(bar_index[10], na, text=&quot;Label&quot;, yloc=yloc.abovebar)
</code></pre><p>&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x4EE4;&#x4EBA;&#x56F0;&#x60D1;&#xFF0C;&#x4F46;&#x5F88;&#x5C11;&#x53D1;&#x751F;&#x3002;&#x968F;&#x7740;&#x65F6;&#x95F4;&#x7684;&#x63A8;&#x79FB;&#xFF0C;Pine &#x56E2;&#x961F;&#x5E0C;&#x671B;&#x80FD;&#x591F;&#x6D88;&#x9664;&#x5B83;&#x4EEC;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="5context.html" class="navigation navigation-prev " aria-label="Previous page: 上下文切换和 security 函数">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="7extend.html" class="navigation navigation-next " aria-label="Next page: 延长和扩展交易数据">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"绘图","level":"1.5.6","depth":2,"next":{"title":"延长和扩展交易数据","level":"1.5.7","depth":2,"path":"features/7extend.md","ref":"./features/7extend.md","articles":[]},"previous":{"title":"上下文切换和 security 函数","level":"1.5.5","depth":2,"path":"features/5context.md","ref":"./features/5context.md","articles":[]},"dir":"ltr"},"config":{"plugins":["livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"剑客","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Pine Script 用户手册中文版","language":"zh","gitbook":"*","description":"Pine Script 文档中文翻译"},"file":{"path":"features/6drawing.md","mtime":"2021-06-12T07:47:53.011Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-06-14T07:42:18.199Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

